#include <stdio.h>
#include <stdlib.h>
#include "simulator.h"

int yyparse();
extern FILE *yyin;

// to indicate whether an semantic error has occurred in the yacc
int hasError = 0;

int main(int argc, char **argv) {
	if(argc < 2) {
		printf("Usage: mix assembly file\n");
		exit(1);	
	}
	yyin = fopen(argv[1], "r");
	if(!yyin) {
		printf("Can not open %s\n", argv[1]);
		exit(1);
	}
	if(!yyparse() && !hasError) {
		printf("parse successfully\n");
		simulate();
	}
	else 
		printf("parse unsuccessfully\n");
	fclose(yyin);
	return 0;
}


